package cs348a.opengl.object;

import java.awt.Color;
import java.util.List;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;

import cs348a.data.Site;
import cs348a.data.TourData;

public class OpenGLTourPath extends AbstractOpenGLObject{

	private List<Site> siteList;
	
	public Color pathColor = Color.WHITE;
	
	public OpenGLTourPath(TourData td) {
		siteList = td.siteList;
	}

	public OpenGLTourPath(List<Site> list) {
		siteList = list;
	}
	
	@Override
	protected void drawComponent(GLAutoDrawable drawable) {
		GL gl = drawable.getGL();
		
		int len = siteList.size();
		
		// draw edges
		for(int i = 0; i < len-1; i++) {
			gl.glBegin(GL.GL_LINES);
				Site org = siteList.get(i);
				gl.glColor3f(pathColor.getRed()/255f, 
						pathColor.getGreen()/255f, 
						pathColor.getBlue()/255f);
				gl.glVertex3f(org.x, org.y, org.z);
				
				Site dst = siteList.get(i+1);
				gl.glColor3f(pathColor.getRed()/255f, 
						pathColor.getGreen()/255f, 
						pathColor.getBlue()/255f);
				gl.glVertex3f(dst.x, dst.y, dst.z);
			gl.glEnd();
		}
	}

}
